package common.Utils;

import java.util.List;

public class StringUtils 
{
	public static boolean containsLetter(String str)
	{
		boolean retVal = false;
		if(str != null && !str.equals(""))
		{
			for(char c : str.toCharArray())
				if(Character.isLetter(c))
				{
					retVal = true;
					break;
				}
		}
		else retVal = true;
		
		return retVal;
	}
	
	public static List<String> findStrings(String str)
	{
		List<String> strings = new LinkedSet<String>();
		String innerString = "";
		boolean settingString = false;
		
		for(char c : str.toCharArray())
		{
			if(Character.isLetter(c))
			{
				settingString = true;
				innerString += c;
			}
			else if(Character.isWhitespace(c) && settingString)
				innerString += c;
			else if(settingString)
			{
				strings.add(innerString);
				innerString = "";
				settingString = false;
			}
		}
		
		return strings;
	}
	
	/*public static void initStringFields(String value, Object obj)
	{
		for(Field field : obj.getClass().getDeclaredFields())
			if(field.getType() == String.class)
			{
				try
				{
					field.setAccessible(true);
					field.set(obj, value);
					field.setAccessible(false);
				}
				catch(Exception e){}
			}
	}*/
}
